package com.yc.thread.basic;

/**
 *
 * @author zwei
 * @create 2024-07-15 10:16
 */
public class Test13_join {
    public static void main(String[] args) throws InterruptedException {
        LifeCirle lc = new LifeCirle();
        System.out.println(lc.isAlive());   //线程状态值
        lc.start();
        System.out.println(lc.isAlive());
        lc.join();              //让lc线程执行完后 再执行主线程
        System.out.println("主线程执行完毕");
        System.out.println(lc.isAlive());
    }
}

class LifeCirle extends Thread {
    @Override
    public void run() {
        int i = 0;
        while (i++ < 10) {
            System.out.println(Thread.currentThread().getName() + ":" + i);
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
